local decode = require "autogen.autogen_module".Decode

local NetworkManager = { }

-- local decode = require "autogen.autogen_modules".Decode
local event = require "Event.Event"

function NetworkManager.initialize()
    
end

function NetworkManager:onReceiveMsg(msgId, data)
    CS.UnityEngine.Debug.Log(msgId)

    local length = data:len()

    if length == 1 then
        event.dispatch(data:byte(1, 1));
    else
        local message = decode(msgId, data);
        processor[msdId](message);
    end
end

function NetworkManager.sendMsg(msgId, data)
    CS.Kylin.NetworkManager.Instance:SendMessage(msgId, data)
end

function NetworkManager.encode(msgId, data) 
    return NetworkMessageEncoder[msgId](data)
end

function NetworkManager.onDisconnect()
    CS.Kylin.NetworkManager.Instance:OnDisconnect()
end

function NetworkManager.connect(ip, port)
    
end

return NetworkManager
